package bar.dark.lee.setting.category;

import java.util.ArrayList;
import java.util.List;

import bar.dark.lee.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CategoryAdapter extends ArrayAdapter<CategoryData>
{
	private ArrayList<CategoryData> list;

	public CategoryAdapter(Context context, int textViewResourceId,
			ArrayList<CategoryData> list)
	{
		super(context, textViewResourceId, list);
		this.list = list;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		View v = convertView;
		
		if (v == null)
		{
			LayoutInflater li = (LayoutInflater) getContext().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
			v = li.inflate(R.layout.list_item_category, null);
		}
		
		CategoryData data = list.get(position);
		
		TextView kind = (TextView) v.findViewById(R.id.listCategoryKind);
		TextView count = (TextView) v.findViewById(R.id.listCategoryCount);
		
		kind.setText(data.getKind());
		count.setText(data.getCount());
		
		return v;
	}
}
